package cn.bdqn.veh.controller;

import cn.bdqn.model.PageBean;
import cn.bdqn.veh.model.Leader;
import cn.bdqn.veh.service.LeaderService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author gurilla
 * @create 2019-08-19 11:26
 */
@Controller
@RequestMapping("/veh/leader")
public class LeaderController {

    @Resource
    private LeaderService leaderService;

    @RequiresPermissions("veh:leader:page")
    @GetMapping
    public String topage(){
        return "/veh/leader";
    }

    @RequiresPermissions("veh:leader:list")
    @PostMapping("list")
    @ResponseBody
    public Object list(PageBean pageBean, String lname, String phone, String idcard){
        return leaderService.list(pageBean, lname, phone, idcard);
    }

    @RequiresPermissions("veh:leader:save")
    @PostMapping("save")
    @ResponseBody
    public Object save(Leader leader){
        return leaderService.save(leader);
    }

    @RequiresPermissions("veh:leader:delete")
    @PostMapping("delete")
    @ResponseBody
    public Object delete(Integer id){
        return leaderService.delete(id);
    }

}
